package edu.hgnc.obverser.test01;

import java.util.ArrayList;
import java.util.List;

public class BadMan implements Observable{

	// 观察者集合
	private List<Observer> observers = new ArrayList<>();
	/**
	 * @param observer
	 */
	@Override
	public void addObserver(Observer observer) {
		this.observers.add(observer);
	}

	/**
	 * @param observer
	 */
	@Override
	public void deleteObserver(Observer observer) {
		this.observers.remove(observer);
	}

	/**
	 * @param s
	 */
	@Override
	public void notifyObserver(String s) {
		observers.forEach(e->{
			e.make("");
		});
	}

	public void run(){
		System.out.println("罪犯要逃跑了~~~");
		this.notifyObserver("追击罪犯");
	}

	public void play(){
		System.out.println("罪犯在玩~~~");
		this.notifyObserver("不要打草惊蛇，静观其变");
	}
}
